home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.4 KB | 47 lines | [TEXT/ttxt] |
- --<<<-
- -- Filename:
- -- mywin.sx
-
- -- Purpose:
- -- Defines the class MyWindowClass.
- -- Provides an implementation for printWindow that prints the offscreen
- -- representation of the window.
- class MyWindowClass (Window)
- end
-
- method printWindow self {class MyWindowClass} -> (
- local surface, scaleFactor, myTransform, oldRate
-
- -- Create PrinterSurface
- surface := new PrinterSurface
-
- -- We calculate the ratio of our width and height to
- -- that of the surface.The minimum of the two ratios
- -- is what we'll use to scale our bitmap.
- scaleFactor := min (surface.boundary.width / self.boundary.width) \
- (surface.boundary.height / self.boundary.height)
-
- -- Create a transformation matrix that represents the scaling
- myTransform := mutableCopy identityMatrix
- scale myTransform scaleFactor scaleFactor
-
- -- Bring up the printer dialog and see if we should continue
- if (printerDialog surface) do (
- -- Stop the window's clock so as to halt the presentation
- oldRate := self.clock.rate
- self.clock.rate := 0
-
- -- Tranfer the Window's off-screen representation
- -- to the PrinterSurface with the appropriate scaling
- transfer surface (snapshot self undefined) \
- surface.boundary mytransform
-
- -- Restart the window's clock
- self.clock.rate := oldRate
-
- -- Flush the document
- flushDocument surface
- )
- )
- -->>>
-